﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace WindowsFormsTraceTester
{
    public partial class TraceTestForm : Form
    {
        public TraceTestForm()
        {
            InitializeComponent();
        }

        private void TraceTestForm_Load(object sender, EventArgs e)
        {
            Trace.WriteLine("Loading Form");
            TraceListener trlistener = new GridViewTraceListener.GridViewTraceListener(dgvTraceView, lblCounter);
            // Comment this if you dont want to trace debug.writeline
            Debug.Listeners.Add(trlistener);
            Trace.Listeners.Add(trlistener);
            Trace.WriteLine("Loading Form Complete");
            Trace.WriteLine("Listener    Activated, Click Simulate Trace");
        }

        private void btnSimulateTrace_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 10; i++)
            {
                Trace.WriteLine("Trace Message id is " + i.ToString()  );
            }
        }
    }
}
